﻿using System.Data.SqlClient;
using Microsoft.ApplicationBlocks.Data;

namespace NTTDATA.BEENChina.ResultCertification.DataStore
{
    public class JaPrefixTelClientAccess:IJaPrefixTelClientAccess
    {

        private static string ConnectionString
        {
            get
            {
                return System.Configuration.ConfigurationManager.AppSettings["ResultCertificationDB"];
            }
        }

       public  bool FindPrefixTel(string prefixTel,int telLength)
       {
           
           string sql = "SELECT COUNT(*)  FROM [JaPrefixTel] WHERE PrefixTel = @PrefixTel AND TelLength= @TelLength";

           SqlParameter[] sqlParameters = 
                {
                    new SqlParameter("@PrefixTel",  prefixTel),
                    new SqlParameter("@TelLength",  telLength)

                };

           string result = SqlHelper.ExecuteScalar(ConnectionString, System.Data.CommandType.Text, sql, sqlParameters).ToString();

           int count = 0;

           int.TryParse(result, out count);

           return count > 0;

       }
    }
}
